import threading
g_number = 0
def funcA(lock):
    global g_number
    with lock:
        for i in range(1000000):
            g_number += 1

def funcB(lock):
    global g_number
    lock.acquire()
    for i in range(1000000):
        g_number += 1
    lock.release()

def main():
    lock = threading.Lock()
    thd1 = threading.Thread(target=funcA, args=(lock,))
    thd2 = threading.Thread(target=funcB, args=(lock,))
    thd1.start()
    thd2.start()
    thd1.join()
    thd2.join()
    print(g_number)


if __name__ == '__main__':
    main()